<?php
/**
 * Autor:   Miguel A. Zilli
 * Email:   miguelzilli@gmail.com
 */

class CanalesRevision extends AppModel {
    var $name = 'CanalesRevision';
    var $useTable = 'canales_revisiones';
    var $primaryKey = 'id';
    var $displayField = 'valoracion_can_prod';
    var $recursive = 0;
    var $order=array(
        'CanalesRevision.valoracion_can_prod'=>'ASC'
    );

    var $validate = array(
        'valoracion_can_prod' =>array(
            array('rule'=>'numeric','message'=>'Solo se permiten números.','allowEmpty' => false),
            array('rule'=>'notEmpty','message'=>'Debe completar este dato.','required' => true)
        )
    );

    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $belongsTo = array(
        'Canal' => array(
            'className' => 'Canal',
            'foreignKey' => 'canal_id'
        ),
        'Revision' => array(
            'className' => 'Revision',
            'foreignKey' => 'revision_id'
        )
    );

    public function beforeSave(){
        if(!empty($this->data['CanalesRevision'])){
            foreach($this->data['CanalesRevision'] as $campo=>$valor){
                $this->data['CanalesRevision'][$campo]=strtoupper($valor);
            }
        }
        return true;
    }
}
?>